package com.fu.plugin.actions;

import com.fu.plugin.filter.MyChooseByNameFilter;
import com.fu.plugin.model.FilterModel;
import com.intellij.ide.actions.GotoActionBase;
import com.intellij.ide.util.gotoByName.ChooseByNameFilter;
import com.intellij.ide.util.gotoByName.ChooseByNamePopup;
import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.openapi.actionSystem.AnActionEvent;
import org.jetbrains.annotations.NotNull;


public class NewGotoActionBase extends GotoActionBase {

    @Override
    protected void gotoActionPerformed(@NotNull AnActionEvent anActionEvent) {
        MyChooseByname chooseByname = new MyChooseByname();
        ChooseByNameContributor[] butor = new ChooseByNameContributor[]{chooseByname};
        FilterModel model = new FilterModel(anActionEvent.getProject(), butor);

        //初始化回调函数
        GotoActionCallback callback = new GotoActionCallback() {
            @Override
            public void elementChosen(ChooseByNamePopup chooseByNamePopup, Object o) {

            }
            @Override
            public ChooseByNameFilter createFilter(@NotNull ChooseByNamePopup popup){
                return new MyChooseByNameFilter(popup, model, anActionEvent.getProject());
            }
        };
        showNavigationPopup(anActionEvent, model, callback);
    }
}
